using UnityEngine;
using System.Collections;
using System.Xml;
using System.IO;
using System.Text;
using System;
using BaseUtil;
using System.Collections.Generic;

public class bodyPart:IXMLData
{
    public int type;
    public string src;
    public override void WriteToBuf(NetOutStream outs)
    {
        outs.Write(type);
        outs.Write(src);
    }
    public override void ReadFromBuf(NetInStream ins)
    {
        ins.Read(ref type);
        ins.Read(ref src);
    }
}

public class Dress : IXMLData
{
    public int id = 0;
    public string name = "";
    public int gender = 0;
    public int type = 0;
    public int sub_type = 0;
    public bool can_overlay = false;
    public int star_level = 1;
    public string icon="";
    public string intro="";
    public bool limit=false;
    public int item_level=0;
    public bool show_inbag=true;
    public bool safe_Show = true;
    public List<bodyPart> bodypartlist = new List<bodyPart>();

    public override void WriteToBuf(NetOutStream outs)
    {
        outs.Write(id);
        outs.Write(name);
        outs.Write(gender);
        outs.Write(type);
        outs.Write(sub_type);
        outs.Write(can_overlay);
        outs.Write(star_level);
        outs.Write(icon);
        outs.Write(intro);
        outs.Write(limit);
        outs.Write(item_level);
        outs.Write(show_inbag);
        outs.Write(safe_Show);

        int count = bodypartlist.Count;
        outs.Write(count);
        for (int i = 0; i < count; i++)
        {
            bodyPart bp = bodypartlist[i];
            bp.WriteToBuf(outs);
            
        }

    }
    public override void ReadFromBuf(NetInStream ins)
    {
        ins.Read(ref id);
        ins.Read(ref name);
        ins.Read(ref gender);
        ins.Read(ref type);
        ins.Read(ref sub_type);
        ins.Read(ref can_overlay);
        ins.Read(ref star_level);
        ins.Read(ref icon);
        ins.Read(ref intro);
        ins.Read(ref limit);
        ins.Read(ref item_level);
        ins.Read(ref show_inbag);
        ins.Read(ref safe_Show);
        int count = 0;
        ins.Read(ref count);
        for (int i = 0; i < count; i++)
        {
            bodyPart bp = new bodyPart();
            bp.ReadFromBuf(ins);
            bodypartlist.Add(bp);
        }
    }
}
public class DressListInfo : IXMLData
{
    public List<Dress> dress_list = new List<Dress>();

    public override void WriteToBuf(NetOutStream outs)
    {
        int count = dress_list.Count;
        outs.Write(count);
        for(int i = 0 ; i < count ; i++)
        {
            Dress dress = dress_list[i];
            dress.WriteToBuf(outs);
        }
    }
    public override void ReadFromBuf(NetInStream ins)
    {
        if (Consts.EXAMPLE1_USE_CAPACITY)
        {
            XMLBuffHelper.ReadFromBuf(ref dress_list, ins);
        }
        else
        {
            int count = 0;
            ins.Read(ref count);
            for (int i = 0; i < count; i++)
            {
                Dress dress = new Dress();
                dress.ReadFromBuf(ins);
                dress_list.Add(dress);
            }
        }
    }
}